2 module
.exports = function ( grunt
) {
3 grunt
.loadNpmTasks( 'grunt-contrib-copy' );
4 grunt
.loadNpmTasks( 'grunt-contrib-jshint' );
5 grunt
.loadNpmTasks( 'grunt-contrib-watch' );
6 grunt
.loadNpmTasks( 'grunt-banana-checker' );
7 grunt
.loadNpmTasks( 'grunt-jscs' );
8 grunt
.loadNpmTasks( 'grunt-jsonlint' );
9 grunt
.loadNpmTasks( 'grunt-karma' );
11 var wgServer
= process
.env
.MW_SERVER
,
12 wgScriptPath
= process
.env
.MW_SCRIPT_PATH
,
15 karmaProxy
[wgScriptPath
] = wgServer
+ wgScriptPath
;
18 pkg
: grunt
.file
.readJSON( 'package.json' ),
25 '{includes,languages,resources,tests}/**/*.js'
31 // Auto-generated file with JSON (double quotes)
32 '!tests/qunit/data/mediawiki.jqueryMsg.data.js',
33 // Skip functions are stored as script files but wrapped in a function when
34 // executed. node-jscs trips on the would-be "Illegal return statement".
35 '!resources/src/*-skip.js'
37 // Exclude all files ignored by jshint
38 ].concat( grunt
.file
.read( '.jshintignore' ).split( '\n' ).reduce( function ( patterns
, pattern
) {
39 // Filter out empty lines
40 if ( pattern
.length
&& pattern
[0] !== '#' ) {
41 patterns
.push( '!' + pattern
);
49 '{languages,maintenance,resources}/**/*.json',
54 core
: 'languages/i18n/',
55 api
: 'includes/api/i18n/',
56 installer
: 'includes/installer/i18n/'
61 '<%= jsonlint.all %>',
71 pattern
: wgServer
+ wgScriptPath
+ '/index.php?title=Special:JavaScriptTest/qunit/export',
76 frameworks
: [ 'qunit' ],
77 reporters
: [ 'dots' ],
80 // Some tests in extensions don't yield for more than the default 10s (T89075)
81 browserNoActivityTimeout
: 60 * 1000
84 browsers
: [ 'Chrome' ]
87 browsers
: [ 'Chrome', 'Firefox' ]
92 src
: 'resources/**/*',
93 dest
: 'docs/js/modules',
95 rename: function ( dest
, src
) {
96 return require( 'path' ).join( dest
, src
.replace( 'resources/', '' ) );
102 grunt
.registerTask( 'assert-mw-env', function () {
103 if ( !process
.env
.MW_SERVER
) {
104 grunt
.log
.error( 'Environment variable MW_SERVER must be set.\n' +
105 'Set this like $wgServer, e.g. "http://localhost"'
108 if ( !process
.env
.MW_SCRIPT_PATH
) {
109 grunt
.log
.error( 'Environment variable MW_SCRIPT_PATH must be set.\n' +
110 'Set this like $wgScriptPath, e.g. "/w"');
112 return !!( process
.env
.MW_SERVER
&& process
.env
.MW_SCRIPT_PATH
);
115 grunt
.registerTask( 'lint', ['jshint', 'jscs', 'jsonlint', 'banana'] );
116 grunt
.registerTask( 'qunit', [ 'assert-mw-env', 'karma:main' ] );
118 grunt
.registerTask( 'test', ['lint'] );
119 grunt
.registerTask( 'default', 'test' );